<template>
    <view>
		<view class="chaxunorderbox">
			<view class="chaxunorder">
				<input type="text" :placeholder="$t('fengcheche.classinfo.writema')" class="form-item margin-vertical-main wh-auto yxformplus-item" @blur="yxblur" @confirm="yxblur">
			</view>
			<view class="form-gorup form-gorup-submit">
				<button class="cr-white round text-size" :style="'background:linear-gradient(107deg, ' + diytheme.main_color + ' 0%, ' + diytheme.main_color + ' 100%)'" type="default" @click="goods_buy_confirm_event" hover-class="none">{{$t('common.submit')}}</button>
			</view>
		</view>
    </view>
</template>
<script>
	const app = getApp();
	import {system_base_info} from "@/common/js/common/common";
    export default {
        data() {
            return {
                data_list_loding_status: 1,
                data_bottom_line_status: false,
				form_submit_loading: false,
				input_keyword_value:'',
				diytheme:null,
				lang_info:null,
            };
        },
		
        onLoad(params) {
			uni.setNavigationBarTitle({
			    title: this.$t('fengcheche.classinfo.writema')
			});
			
			// 数据加载
			this.init();
        },

        // 下拉刷新
        onPullDownRefresh() {
            this.init();
        },

        methods: {
			// 加载之前
			init() {
				// 先获取语言基础信息 
				system_base_info()
				.then(data=>{
					this.init_before(data)
					.then(()=>{
						this.init_real();
					});
				});
			},
			// 设置本页参数
			init_before(data){
				var self = this;
				return new Promise((resolve, reject) => {
					self.setData({
						lang_info: data.system_lang_info,
						diytheme: data.diytheme,
					});
					resolve();
				});
			},
			
            init_real() {
                var user = app.globalData.get_user_info(this, 'init');
                if (user == false) {
                    app.globalData.showToast(this.$t('fengcheche.cutprice.app_please_login_msg'));
                }
            },
			
			// 随时记录输入的关键字
			yxblur(e){
				var value = e.detail.value;
				this.setData({
					input_keyword_value:value
				});
			},
			
			// 提交
			goods_buy_confirm_event(e) {
				var self = this;
			    // 数据验证
			    if(this.input_keyword_value == ''){
					app.globalData.showToast(this.$t('fengcheche.classinfo.manotempty'));
					return false;
				}
				
				uni.showLoading({
					title: this.$t('buy.buy.r79t77')
				});
				this.setData({
					form_submit_loading: true
				});
			        
				// 网络请求
				uni.request({
					url: app.globalData.get_request_url('peoplesave', 'company', 'classinfo'),
					method: 'POST',
					data: {
						keywords: this.input_keyword_value,
					},
					dataType: 'json',
					success: res => {
						uni.hideLoading();
						if (res.data.code == 0) {
						    app.globalData.showToast(res.data.msg, 'success');
						    setTimeout(function () {
						        app.globalData.page_back_prev_event();
						    }, 2000);
						} else {
						    this.setData({
						        form_submit_loading: false,
						    });
						    if (app.globalData.is_login_check(res.data)) {
						        app.globalData.showToast(res.data.msg);
						    } else {
						        app.globalData.showToast(this.$t('common.sub_error_retry_tips'));
						    }
						}
					},
					fail: () => {
						uni.hideLoading();
						this.setData({
							form_submit_loading: false
						});
						app.globalData.showToast(this.$t('common.internet_error_tips'));
					}
				});
			}
        }
    };
</script>
<style>
    .chaxunorderbox{padding:40rpx;}
    .chaxunorder{margin-bottom: 40rpx;}
    .chaxunorder input{border:1px solid #ddd;height:75rpx;border-radius: 5px;padding:0 15rpx;line-height: 75rpx;background-color: #fff;box-sizing: border-box;}
</style>